package com.atjinggu.jinggumail.search.controller;

import com.atjinggu.jinggumail.search.service.SearchService;
import com.atjinggu.jinggumail.search.vo.SearchParamVo;
import com.atjinggu.jinggumail.search.vo.SearchResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author jingming
 * @Type SearchController.java
 * @Desc
 * @date 2021/1/22 11:56
 */
@Controller
public class SearchController {

    @Autowired
    SearchService searchService;

    @GetMapping("/list.html")
    public String  listPage(SearchParamVo paramVo, Model model, HttpServletRequest request, HttpSession session) throws IOException {
        paramVo.set_queryString(request.getQueryString());
        SearchResultVo resultVo =  searchService.search(paramVo);
        model.addAttribute("result",resultVo);
        System.out.println(session.getId());
        return "list";
    }


}